<?php
	include_once("./inc_classes.php");
	$table_name = 'ggoggo_board';
	$db = new Nmysql();
	$pagenation_cfg = array(
			'uri'                           => "list.php.php",
			'articles_count'                => 20,
			'req_page'                      => empty($_GET['p1'])? 0 : $_GET['p1'],
			'page_size'                     => 6,
			'articles_cnt'                  => $db->getcnts($table_name),
			'style'                         => Pagenation::$style_default,
			'get'                           => 'p1'
	);
	$article = $db->gets(
		$q = sprintf("SELECT * FROM `%s` ORDER BY uid DESC LIMIT %s, %s ",
			$table_name,
			$pagenation_cfg['req_page'] * $pagenation_cfg['articles_count'],
			$pagenation_cfg['articles_count']
		)
	);

	$pagenation = Pagenation::out($pagenation_cfg);

?><!doctype html>
<html lang="ko">
<head>
<title>ggoggoboard</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" />
<![endif]-->
</head>
<body>

	<?php if($article['cnt'] > 0): ?>

		<table border="1">
			<colgroup>
				<col width="10%" />
				<col width="50%" />
				<col width="20%" />
				<col width="10%" />
			</colgroup>
			<thead>
				<tr>
					<th>uid</th>
					<th>subject</th>
					<th>name</th>
					<th>date</th>
				</tr>
			</thead>

			<tbody>
				<?php foreach($article['res'] as $key=>$val) : ?>
					<tr>
						<td class="first"><?php echo $val['uid']?></td>
						<td><a href="./retrieve.php?uid=<?php echo $val['uid']?>&p1=<?php echo isset($_GET['p1'])?$_GET['p1']:0?>"><?php echo $val['subject']?></a></td>
						<td><?php echo $val['name']?></td>
						<td><?php echo $val['date']?></td>
					</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
	<?php else : ?>
		내용이 없습니다.
	<?php endif; ?>
	<div><?=$pagenation?></div>
	<div><a href="create.php?p1=<?php echo isset($_GET['p1'])?$_GET['p1']:0?>">작성</a></div>
</body>
</html>